#ifndef els_mem_h
#define els_mem_h


#include <stddef.h>

#include "els.h"

void *els_Mem_realloc (els_VmObj *L, void *oldblock, lint32 size);
void *els_Mem_growaux (els_VmObj *L, void *block, size_t nelems,int inc, size_t size, const char *errormsg,size_t limit);

#define els_Mem_free(L, b)		                    els_Mem_realloc(L, (b), 0)
#define els_Mem_malloc(L, t)	                    els_Mem_realloc(L, NULL, (t))
#define els_Mem_new(L, t)                           ((t *)els_Mem_malloc(L, sizeof(t)))
#define els_Mem_newvector(L, n,t)                   ((t *)els_Mem_malloc(L, (n)*(lint32)sizeof(t)))

#define els_Mem_growvector(L, v,nelems,inc,t,e,l)   ((v)=(t *)els_Mem_growaux(L, v,nelems,inc,sizeof(t),e,l))
#define els_Mem_reallocvector(L, v,n,t)             ((v)=(t *)els_Mem_realloc(L, v,(n)*(lint32)sizeof(t)))

#endif

